﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using SE560Multimedia.src;

namespace SE560Multimedia.pages
{
    public partial class LoginForm : System.Web.UI.Page
    {
        SessionManager sessionManager;

        protected void Page_Load(object sender, EventArgs e)
        {
            sessionManager = new SessionManager(Session);
        }

        protected void LoginScreen_LoggedIn(object sender, EventArgs e)
        {
            ProjectDataSetTableAdapters.userTableAdapter usrTableAdapter =
                new ProjectDataSetTableAdapters.userTableAdapter();

            ProjectDataSetTableAdapters.playlistTableAdapter plyListTableAdapter =
                new ProjectDataSetTableAdapters.playlistTableAdapter();
            // Attach user name and id to session
            sessionManager.SessionLoggedUserName =
                (String)usrTableAdapter.GetUsernameByEmail(LoginMainScreen.UserName);
            sessionManager.SessionLoggedUserId =
                usrTableAdapter.GetUserIdByEmail(LoginMainScreen.UserName).Value;
            sessionManager.SessionLoggedPlaylistID = 
                plyListTableAdapter.GetPlaylistIdByUserId( sessionManager.SessionLoggedUserId ).Value ;
        }
    }
}
